package com.xh.xyzp.controller;

import com.xh.xyzp.common.domain.vo.resp.ApiResult;
import com.xh.xyzp.common.domain.vo.resp.PageResp;
import com.xh.xyzp.domain.entity.Deliver;
import com.xh.xyzp.domain.vo.DeliverPageReq;
import com.xh.xyzp.domain.vo.DeliverResp;
import com.xh.xyzp.domain.vo.DeliverSubmitReq;
import com.xh.xyzp.service.DeliverService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@Api(tags = "投递接口")
@RestController
@RequestMapping("/deliver")
public class DeliverController {

    @Autowired
    private DeliverService deliverService;

    @ApiOperation("详细信息")
    @PostMapping("/info/{deliverId}")
    public ApiResult<DeliverResp> getInfo(@PathVariable("deliverId") Long deliverId) {
        return ApiResult.success(deliverService.getInfo(deliverId));
    }

    @ApiOperation("新增/编辑")
    @PostMapping("/submit")
    public ApiResult<Void> submit(@RequestBody DeliverSubmitReq req) {
        deliverService.submit(req);
        return ApiResult.success();
    }

    @ApiOperation("列表")
    @PostMapping("/list")
    public ApiResult<PageResp<DeliverResp>> getList(@RequestBody DeliverPageReq req) {
        return ApiResult.success(deliverService.getList(req));
    }

    @ApiOperation("管理列表")
    @PostMapping("/admin/list")
    public ApiResult<PageResp<DeliverResp>> getAdminList(@RequestBody DeliverPageReq req) {
        return ApiResult.success(deliverService.getAdminList(req));
    }
} 